import java.util.*;

public class ConsoleState {
	
	private HashMap<String, String[]> options;
	private ArrayList<String> optionsPicked;
	
	public ConsoleState()
	{
		optionsPicked = new ArrayList<String>();
		options=new HashMap<String, String[]>();
		initialize();
	}
	
	public ArrayList<String> getOptionsPicked()
	{
		return optionsPicked;
	}
	
	public void initialize()
	{
		String[] ssds = new String[]{"Search Algorithms", "Sort Algorithms", "Data Structures"};
		
		/*String[] dataStructures = new String[]{ "java.util.ArrayList", "java.util.Stack", "java.util.LinkedList", 
											   "java.util.PriorityQueue", "java.util.HashMap", "java.util.TreeMap", 
											   "java.util.TreeSet", "java.util.HashSet"};*/
		
		String[] dataStructures = new String[]{/*"Array",*/ "java.util.ArrayList", "java.util.Stack", "java.util.LinkedList", 
				   "java.util.PriorityQueue", 
				   "java.util.TreeSet", "java.util.HashSet"};
		
		String[] searching = new String[]{"sequentialSearch(Object key)", "binarySearch(ArrayList<Integer> ints, Object o)"};
		
		String[] sorting = new String[]{"bubbleSort()", "selectionSort()", "insertionSort()", "mergeSort()", "quickSort()"};
		
		String[] arrayListMethods = new String[]{"add(E e)", "add(int index, E element)", "contains(Object o)", "get(int index)",
	   		     "indexOf(Object o)", "remove(int index)", "remove(Object o)", "set(int index, E element)"};
		
		String[] stackMethods = new String[]{"empty()", "pop()", "peek()", "push(Object o)"};
		
		String[] linkedListMethods = new String[]{"add(E e)", "add(int index, E element)", "addFirst(E e)", "addLast(E e)",
												  "contains(Object o)", "get(int index)", "clear()", "indexOf(Object o)",
												  "remove()", "remove(int index)", "remove(Object o)", "poll()", "peek()",
												  "set(int index, E e)"};
		
		String[] priorityQueueMethods  = new String[]{"size()", "poll()", "peek()", "remove(Oject o)", "add(E e)", "contains(Object o)"};
		
		String[] hashMapMethods = new String[]{"containsKey(Object key)", "containsValue(Object value)", "get(Object key)",
											   "isEmpty()", "put(K key, V value)", "remove(Object key)", "size()"};
		
		String[] treeMapMethods = new String[]{"containsKey(Object key)", "containsValue(Object value)", "get(Object key)",
											   "isEmpty()", "put(K key, V value)", "remove(Object key)", "size()"};
		
		String[] hashSetMethods = new String[]{"add(E e)", "contains(Object o)", "isEmpty()", "remove(Object o)", "size()"};
		
		String[] treeSetMethods = new String[]{"add(E e)", "contains(Object o)", "isEmpty()", "remove(Object o)", "size()"};
		
		//HashMap<String, String[]> temp = new HashMap<String, String[]>();
		options.put("Algorithms and Data Structures", ssds);
		options.put("Search Algorithms", searching);
		options.put("Sort Algorithms", sorting);
		options.put("Data Structures", dataStructures);
		options.put("java.util.ArrayList", arrayListMethods);
		options.put("java.util.Stack", stackMethods);
		options.put("java.util.LinkedList", linkedListMethods);
		options.put("java.util.PriorityQueue", priorityQueueMethods);
		options.put("java.util.HashMap", hashMapMethods);
		options.put("java.util.TreeMap", treeMapMethods);
		options.put("java.util.TreeSet", treeSetMethods);
		options.put("java.util.HashSet", hashSetMethods);
	}
	public ArrayList<String> optionsPicked()
	{
		return optionsPicked;
	}
	
	public String[] access(String s)
	{
		optionsPicked.add(s);
		return options.get(s);
	}
	public String[] accessNoUpdate(String s){
		return options.get(s);
	}
	public void updateDepth(int newDepth)
	{
		for(int i = optionsPicked.size()-1; i >= newDepth; i--)
			optionsPicked.remove(i);
	}
}
